/**
 * @projectName gs_online
 * @package com.answer.wx.controller
 * @className com.answer.wx.controller.UserController
 */
package com.answer.wx.gateway.controller;

import com.answer.wx.common.aop.ApiOptions;
import com.answer.wx.dao.model.User;
import com.answer.wx.gateway.config.filter.RequestInfoHolder;
import com.answer.wx.gateway.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * UserController
 * @description 用户Controller
 * @author answer_wx
 * @date 2022/8/5 23:25
 * @version 1.0
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api(value = "用户接口", tags = {"用户接口"})
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/{appid}/info")
    @ApiOperation("获取用户信息")
    @ApiOptions
    public int save(@RequestBody User user) {
        user.setUserOpenid(RequestInfoHolder.getOpenId());
        return userService.save(user);
    }

    @PostMapping("/check")
    @ApiOperation("校验用户")
    @ApiOptions
    public User checkAdmin(Integer userId) {
        return userService.getById(userId);
    }
}